#自动取款机 登陆、退出、查询余额、存款、取款

accountList=[{'id':'aaa','pwd':'aaa','money':123.0},
            {'id':'bbb','pwd':'bbb','money':123.0},
            {'id':'ccc','pwd':'ccc','money':123.0},
            {'id':'ddd','pwd':'ddd','money':123.0}]

#存储登录账户的信息
cid = ''
cpwd = ''

print("="*20,"银行账户管理系统","="*20)
print("\t1.登录账户\t\t2.退出账户")
print("\t3.存款    \t\t4.取款")
print("\t5.余额查询")
print("="*58)

while True:
    index = input("请输入操作序号：")
#登录账户
    if index =='1':
        print("="*24,"登陆账户","="*24)
        cid = input("账号：")
        cpwd = input("密码：")
        for i in range(len(accountList)):
            if accountList[i]["id"] == cid and accountList[i]["pwd"] == cpwd:
                print("登录成功！")
                break
            else:
                print("登录失败！")
                cid = ''
                cpwd = ''
        print("="*58)
#退出账户       
    elif index =='2':
        print("="*24,"退出账户","="*24)
        if cid == '':
            print("您尚未登录账户!")
        else:
            cid = ''
            cpwd = ''
            print("退出成功！")
            break
        print("="*58)
#存款
    elif index =='3':
        print("="*24,"存款操作","="*24)
        if cid == '':
            print("您尚未登录账户!")
        else:
            m = float(input("请输入存款金额："))
            for i in range(len(accountList)):
                if accountList[i]["id"] == cid and accountList[i]["pwd"] == cpwd:
                    accountList[i]["money"]+=m
                break
            print("存款成功！")
        print("="*58)  
#取款    
    elif index =='4':
        print("="*24,"取款操作","="*24)
        if cid == '':
            print("您尚未登录账户!")
        else:
            m = float(input("请输入取款金额："))
            for i in range(len(accountList)):
                if accountList[i]["id"] == cid and accountList[i]["pwd"] == cpwd:
                    accountList[i]["money"]-=m
                break
            print("取款成功！")
        print("="*58)
#余额查询        
    elif index =='5':
        print("="*24,"余额查询","="*24)
        if cid == '':
            print("您尚未登录账户!")
        else:
            for i in range(len(accountList)):
                if accountList[i]["id"] == cid and accountList[i]["pwd"] == cpwd:
                    m = accountList[i]["money"]
                break
            print("您的账户余额为：",m)
        print("="*58) 
